<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>搜索引擎技巧指南 - 程序员之家技术组</title>
    <link rel="stylesheet" href="style/style1.css">
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
            line-height: 1.8;
            margin: 0;
            padding: 0;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
        }
        
        .container {
            max-width: 1000px;
            margin: 0 auto;
            padding: 40px 20px;
        }
        
        .header {
            text-align: center;
            margin-bottom: 40px;
            color: white;
        }
        
        .header h1 {
            font-size: 2.5em;
            margin-bottom: 10px;
            text-shadow: 0 2px 4px rgba(0,0,0,0.3);
        }
        
        .header p {
            font-size: 1.2em;
            opacity: 0.9;
        }
        
        .content-card {
            background: white;
            border-radius: 20px;
            padding: 40px;
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            margin-bottom: 30px;
        }
        
        .back-button {
            display: inline-flex;
            align-items: center;
            padding: 12px 24px;
            background: #667eea;
            color: white;
            text-decoration: none;
            border-radius: 25px;
            transition: all 0.3s ease;
            margin-bottom: 30px;
            font-weight: 500;
        }
        
        .back-button:hover {
            background: #764ba2;
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        }
        
        .back-button::before {
            content: "←";
            margin-right: 8px;
            font-size: 1.2em;
        }
        
        .xml-content {
            color: #333;
            font-size: 16px;
        }
        
        .xml-content h1 {
            color: #667eea;
            border-bottom: 3px solid #667eea;
            padding-bottom: 10px;
            margin-top: 40px;
            margin-bottom: 20px;
        }
        
        .xml-content h2 {
            color: #764ba2;
            margin-top: 30px;
            margin-bottom: 15px;
            font-size: 1.5em;
        }
        
        .xml-content h3 {
            color: #333;
            margin-top: 25px;
            margin-bottom: 12px;
            font-size: 1.3em;
        }
        
        .tip-section {
            margin: 30px 0;
            padding: 25px;
            background: #f8f9fa;
            border-radius: 15px;
            border-left: 4px solid #667eea;
        }
        
        .tip-card {
            margin: 20px 0;
            padding: 20px;
            background: white;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            border-left: 3px solid #4facfe;
        }
        
        .scenario-card {
            margin: 20px 0;
            padding: 20px;
            background: white;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            border-left: 3px solid #fa709a;
        }
        
        .key-point {
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
            padding: 15px;
            border-radius: 10px;
            margin: 15px 0;
            font-weight: 500;
        }
        
        .tip-box {
            background: #e8f5e8;
            border: 1px solid #4caf50;
            padding: 15px;
            border-radius: 8px;
            margin: 15px 0;
        }
        
        .tool-item {
            margin: 15px 0;
            padding: 15px;
            background: #fff3cd;
            border-radius: 8px;
            border-left: 3px solid #ffc107;
        }
        
        .operators-table table {
            border-collapse: collapse;
            width: 100%;
            margin: 20px 0;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        
        .operators-table th,
        .operators-table td {
            border: 1px solid #ddd;
            padding: 12px;
            text-align: left;
        }
        
        .operators-table th {
            background: #667eea;
            color: white;
            font-weight: 600;
        }
        
        .operators-table tr:nth-child(even) {
            background: #f8f9fa;
        }
        
        code {
            background: #f4f4f4;
            padding: 3px 6px;
            border-radius: 4px;
            font-family: 'Consolas', 'Monaco', monospace;
            color: #e74c3c;
            font-size: 0.9em;
        }
        
        .summary-box {
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
            padding: 25px;
            border-radius: 15px;
            margin: 30px 0;
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
        }
        
        @media (max-width: 768px) {
            .container {
                padding: 20px 10px;
            }
            
            .content-card {
                padding: 25px;
            }
            
            .header h1 {
                font-size: 2em;
            }
            
            .xml-content {
                font-size: 15px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>搜索引擎技巧指南</h1>
            <p>掌握高效搜索的艺术，让信息获取事半功倍</p>
        </div>
        
        <div class="content-card">
            <a href="index.html" class="back-button">返回首页</a>
            
            <div class="xml-content" id="xmlContent">
                <!-- 内容将通过JavaScript动态加载 -->
                <div style="text-align: center; padding: 50px;">
                    <div style="display: inline-block; border: 4px solid #f3f3f3; border-top: 4px solid #667eea; border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite;"></div>
                    <p style="color: #666; margin-top: 20px;">正在加载XML内容...</p>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 从XML文件加载实际数据
        async function loadXMLContent() {
            try {
                const response = await fetch('search-tips.xml');
                if (!response.ok) throw new Error('无法加载XML文件');
                const xmlText = await response.text();
                return xmlText;
            } catch (error) {
                console.error('加载XML失败:', error);
                return null;
            }
        }

        // 渲染XML内容
        function renderXMLContent(xmlText) {
            if (!xmlText) {
                document.getElementById('xmlContent').innerHTML = '<p>加载内容失败，请检查网络连接</p>';
                return;
            }
            
            const parser = new DOMParser();
            const xmlDoc = parser.parseFromString(xmlText, 'text/xml');
            let html = '';
            
            // 主标题和描述
            const title = xmlDoc.querySelector('search-tips > title').textContent;
            const description = xmlDoc.querySelector('search-tips > description').textContent;
            
            html += `<h1>${title}</h1>`;
            html += `<p class="intro">${description}</p>`;
            
            // 各个section
            const sections = xmlDoc.querySelectorAll('section');
            sections.forEach(section => {
                const sectionTitle = section.querySelector('title').textContent;
                const sectionDesc = section.querySelector('description')?.textContent || '';
                
                html += `<div class="tip-section">`;
                html += `<h2>${sectionTitle}</h2>`;
                
                if (sectionDesc) {
                    html += `<p>${sectionDesc}</p>`;
                }
                
                const sectionId = section.getAttribute('id');
                
                switch(sectionId) {
                    case 'basic':
                        const tips = section.querySelectorAll('tip');
                        tips.forEach(tip => {
                            const tipTitle = tip.querySelector('title').textContent;
                            const tipDesc = tip.querySelector('description').textContent;
                            const keyPoint = tip.querySelector('key-point')?.textContent;
                            
                            html += `
                                <div class="tip-card">
                                    <h3>${tipTitle}</h3>
                                    <p>${tipDesc}</p>
                                    ${keyPoint ? `<div class="key-point">${keyPoint}</div>` : ''}
                                </div>
                            `;
                        });
                        break;
                        
                    case 'advanced':
                        const operators = section.querySelectorAll('operators operator');
                        html += '<div class="operators-table">';
                        html += `
                            <table>
                                <thead>
                                    <tr>
                                        <th>运算符</th>
                                        <th>名称</th>
                                        <th>作用</th>
                                        <th>示例</th>
                                    </tr>
                                </thead>
                                <tbody>
                        `;
                        
                        operators.forEach(op => {
                            const symbol = op.querySelector('symbol').textContent;
                            const name = op.querySelector('name').textContent;
                            const purpose = op.querySelector('purpose').textContent;
                            const example = op.querySelector('example').textContent;
                            
                            html += `
                                <tr>
                                    <td><code>${symbol}</code></td>
                                    <td>${name}</td>
                                    <td>${purpose}</td>
                                    <td><code>${example}</code></td>
                                </tr>
                            `;
                        });
                        
                        html += '</tbody></table></div>';
                        break;
                        
                    case 'specific-scenarios':
                        const scenarios = section.querySelectorAll('scenario');
                        scenarios.forEach(scenario => {
                            const name = scenario.querySelector('name').textContent;
                            const method = scenario.querySelector('method')?.textContent || '';
                            const example = scenario.querySelector('example')?.textContent || '';
                            const tip = scenario.querySelector('tip')?.textContent || '';
                            
                            html += `
                                <div class="scenario-card">
                                    <h3>${name}</h3>
                                    ${method ? `<p><strong>方法：</strong>${method}</p>` : ''}
                                    ${example ? `<p><strong>示例：</strong><code>${example}</code></p>` : ''}
                                    ${tip ? `<div class="tip-box">💡 ${tip}</div>` : ''}
                                </div>
                            `;
                        });
                        break;
                        
                    case 'tools':
                        const filters = section.querySelectorAll('filters filter');
                        html += '<ul>';
                        filters.forEach(filter => {
                            const filterName = filter.querySelector('name')?.textContent || filter.textContent;
                            const purpose = filter.querySelector('purpose')?.textContent || '';
                            html += `<li><strong>${filterName}</strong>${purpose ? ': ' + purpose : ''}</li>`;
                        });
                        html += '</ul>';
                        break;
                        
                    case 'advanced-tips':
                        const advancedTips = section.querySelectorAll('tips tip');
                        advancedTips.forEach(tip => {
                            const command = tip.querySelector('command').textContent;
                            const description = tip.querySelector('description').textContent;
                            
                            html += `
                                <div class="tool-item">
                                    <h4><code>${command}</code></h4>
                                    <p>${description}</p>
                                </div>
                            `;
                        });
                        break;
                }
                
                html += '</div>';
            });
            
            // 总结
            const summary = xmlDoc.querySelector('summary');
            if (summary) {
                html += `
                    <div class="summary-box">
                        <h2>总结</h2>
                        <p>${summary.textContent}</p>
                    </div>
                `;
            }
            
            return html;
        }

        // 页面加载完成后加载内容
        document.addEventListener('DOMContentLoaded', async function() {
            const xmlContent = await loadXMLContent();
            const renderedContent = renderXMLContent(xmlContent);
            document.getElementById('xmlContent').innerHTML = renderedContent;
        });
    </script>

    <p>部分由AI生成，请妥善传播</p>
</body>
</html>